/*
 *
 *  Copyright (C) 1997-2011, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module:  dcmjp2
 *
 *  Author:  qinwl,2017.06.27
 *
 *  Purpose: singleton class that registers decoders for all supported JPEG 2000 processes.
 *
 */

#ifndef DJP2DECODE_H
#define DJP2DECODE_H

#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/oftypes.h"  /* for OFBool */
#include "dcmtk/dcmjp2/djp2define.h"

class DcmJ2KCodecParameter;
class DcmJ2KCodecDecoder;

/** singleton class that registers decoders for all supported JPEG processes.
 */
class DCMTK_DCMJP2_EXPORT DcmJ2KDecoderRegistration
{
public:
  /** registers decoders for all supported JPEG 2000 processes.
   *  If already registered, call is ignored unless cleanup() has
   *  been performed before.
   *  @param pCreateSOPInstanceUID flag indicating whether or not
   *    a new SOP Instance UID should be assigned upon decompression.
   *  @param pPlanarConfiguration flag indicating how planar configuration
   *    of color images should be encoded upon decompression.
   *  @param predictor6WorkaroundEnable enable workaround for buggy lossless compressed images with
   *           overflow in predictor 6 for images with 16 bits/pixel
   */
  static void registerCodecs(
	  OFBool pCreateSOPInstanceUID = OFFalse,
	  OFBool pReverseDecompressionByteOrder = OFFalse);

  /** deregisters decoders.
   *  Attention: Must not be called while other threads might still use
   *  the registered codecs, e.g. because they are currently decoding
   *  DICOM data sets through dcmdata.
   */
  static void cleanup();

private:

	/// private undefined copy constructor
	DcmJ2KDecoderRegistration(const DcmJ2KDecoderRegistration&);

	/// private undefined copy assignment operator
	DcmJ2KDecoderRegistration& operator=(const DcmJ2KDecoderRegistration&);

	/// flag indicating whether the decoder is already registered.
	static OFBool registered;

	/// pointer to codec parameter
	static DcmJ2KCodecParameter *cp;

	/// pointer to RLE decoder
	static DcmJ2KCodecDecoder *codec;

};

#endif
